
import { WeElement, define } from 'omi'
import './index.css'
import logo from './jingqu.png'
const app = getApp();
import { get,post, createOrder, toastSuccess, toastErr } from '../../utils/util';
import api from '../../api/api';
define('page-logs', class extends WeElement {
  config = {
    navigationBarTitleText: '我的收藏'
  }
  data = {
    idnum:-1,
    list:[]
  }
  install() {
    this.data.num = 1
    this.data.idnum = app.globalData.idmunber
    post(api.collect, { goods_id: this.data.idnum, goods_type:2}).then((res)=>{
        console.log(res)
    })
    console.log(this.data.idnum,"id")
    post(api.collectdatail).then((res) => {
      console.log(res,"res")
      this.data.list = res.data
      console.log(this.data.list,"this.data.list")
      this.update()
    })
    this.update()
  }
  all = () => {
    this.data.num=1
    this.update()
  }
  house = () => {
    this.data.num =2
    this.update()
  }
  aller = () => {
    this.data.num =3
   this.update()
  }
  render() {

    let { list }=this.data
    return (
      <view>
        <view class="three_tab">
          <text onClick={this.all} class={[this.data.num==1&&'active']}>全部</text>
          <text onClick={this.house} class={[this.data.num==2&&'active']}>酒店</text>
          <text onClick={this.aller} class={[this.data.num==3&&'active']}>客房</text>
        </view>
        {
          this.data.num==1&&
            (list.map( (listitme,index)=>(
              <view class="lists">
                <view class="img_box">
                  <image src={listitme.goods_img}></image>
                </view>
                <view class="text_cen">
                  <text class="name">{listitme.goods_name}</text>
                  <text class="other">¥{listitme.price}</text>
                </view>
              </view>
            ) ))
          
        }
        {
          this.data.num==2&&<view class="abc">456</view>
        }
        {
          this.data.num ==3&&<view class="abc">789</view>
        }
      </view>
    )
  }
})